import Phaser from 'phaser'

/**
 * 导航页面
 */
export default class NavState extends Phaser.State {
  init(...args) {
    console.log('ce---启动导航页面')
  }

  preload(game) {}

  create(game) {
    this.createDisplayObj()
  }

  update(game) {
    super.update(game)
  }

  createDisplayObj() {
    const { game } = this
    const worldWidth = game.world.width
    const worldHeight = game.world.height

    const bgnavImg = game.add.image(0, 0, 'bgnav')
    bgnavImg.width = worldWidth
    bgnavImg.height = worldHeight

    const playText = game.add.text(
      worldWidth / 2 + 5,
      worldHeight / 2 + 35,
      '弹奏吧',
      {
        fontSize: '22px',
        fill: '#333',
        align: 'center',
      },
    )

    playText.anchor.set(0.5)

    playText.inputEnabled = true
    playText.events.onInputUp.add(() => {
      console.log('ce---点击弹奏')
      game.state.start('GameState')
    })

    const historyText = game.add.text(
      90,
      worldHeight / 2 + 80,
      '我\n的\n记\n录',
      {
        fontSize: '22px',
        fill: '#333',
        align: 'center',
        stroke: '#fff',
        strokeThickness: 3,
      },
    )

    historyText.anchor.set(0.5)

    historyText.inputEnabled = true
    historyText.events.onInputUp.add(() => {
      console.log('ce---点击我的记录')
    })
  }
}
